﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using DAL;
using CTRL;

namespace GUI_Client
{
    public partial class ShowBookingDetails : Form
    {
        private static ShowBookingDetails instance;

        private Booking booking;
        private CtrlBookingItem bookItemCtrl;
        private CtrlBatteryStation batStatCtrl;
        private CtrlBatteryItem batItemCtrl;

        private ShowBookingDetails()
        {
            this.booking = GUIBookings.Booking;
            bookItemCtrl = CtrlBookingItem.Instance;
            batStatCtrl = CtrlBatteryStation.Instance;
            batItemCtrl = CtrlBatteryItem.Instance;

            InitializeComponent();

            IEnumerable<BookingItem> items = bookItemCtrl.GetBookingItemsFromBooking(booking.bookingID);

            int count = 0;

                foreach (BookingItem item in items)
                {
                    count++;
                    BatteryItem bi = batItemCtrl.GetBatteryItem(item.batteryID);
                    BatteryStation bs = batStatCtrl.GetBatteryStationByID(bi.stationID);
                    dataGridView.Rows.Add(count, bs.name);
                }
        }

        public static ShowBookingDetails Instance
        {
            get
            {
                if (instance == null)
                    instance = new ShowBookingDetails();

                return instance;
            }
        }

        private void backBtn_Click(object sender, EventArgs e)
        {
            GUIBookings bookings = GUIBookings.Instance;
            bookings.Show();

            this.Hide();
        }
    }
}